/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package me.report.api.web.util;

import java.io.File;

/**
 *
 * @author kuluan
 */
public class AvatarFolderUtils {

    private static final String COMBINE_FOLDER_CHARACTER_NAME = "_";
    private static final String LEVEL_1_FOLDER_NAME = "0M";
    private static final int LEVEL_1_FOLDER_NUMBER = 10000000;
    private static final String LEVEL_2_FOLDER_NAME = "M";
    private static final int LEVEL_2_FOLDER_NUMBER = 1000000;
    private static final String LEVEL_3_FOLDER_NAME = "00K";
    private static final int LEVEL_3_FOLDER_NUMBER = 100000;
    private static final String LEVEL_4_FOLDER_NAME = "0K";
    private static final int LEVEL_4_FOLDER_NUMBER = 10000;
    private static final String LEVEL_5_FOLDER_NAME = "K";
    private static final int LEVEL_5_FOLDER_NUMBER = 1000;

    /**
     * Tu tao duong dan theo userid.
     *
     * @param userid
     * @return
     */
    public static String getPath(int userid) {
//        StringBuilder pathStringBuffer = new StringBuilder();
//        int useNumber = userid;
//        
//        int numberFolder = useNumber / LEVEL_1_FOLDER_NUMBER;
//        pathStringBuffer.append(makeFolderPath(numberFolder, LEVEL_1_FOLDER_NAME));
//        
//        useNumber = useNumber % LEVEL_1_FOLDER_NUMBER;
//        numberFolder = useNumber / LEVEL_2_FOLDER_NUMBER;
//        pathStringBuffer.append(makeFolderPath(numberFolder, LEVEL_2_FOLDER_NAME));
//        
//        useNumber = useNumber % LEVEL_2_FOLDER_NUMBER;
//        numberFolder = useNumber / LEVEL_3_FOLDER_NUMBER;
//        pathStringBuffer.append(makeFolderPath(numberFolder, LEVEL_3_FOLDER_NAME));
//        
//        useNumber = useNumber % LEVEL_3_FOLDER_NUMBER;
//        numberFolder = useNumber / LEVEL_4_FOLDER_NUMBER;
//        pathStringBuffer.append(makeFolderPath(numberFolder, LEVEL_4_FOLDER_NAME));
//        
//        useNumber = useNumber % LEVEL_4_FOLDER_NUMBER;
//        numberFolder = useNumber / LEVEL_5_FOLDER_NUMBER;
//        pathStringBuffer.append(makeFolderPath(numberFolder, LEVEL_5_FOLDER_NAME));
//        
//        pathStringBuffer.append(userid);
//        pathStringBuffer.append(File.separator);
//        
//        return ApiIwinSingleton.getInstance().getConfig().getString("media_path")+ pathStringBuffer.toString(); 
        return "";
    }

    /**
     * Tao folder theo range cua folder name.
     *
     * @param numberFolder
     * @param folderName
     * @return
     */
    private static String makeFolderPath(int numberFolder, String folderName) {
        StringBuilder sb = new StringBuilder();
        sb.append(numberFolder);
        sb.append(folderName);
        sb.append(COMBINE_FOLDER_CHARACTER_NAME);
        numberFolder++;
        sb.append(numberFolder);
        sb.append(folderName);
        sb.append(File.separator);
        return sb.toString();
    }
}
